import React from "react";
import { Typography } from "antd";
import { QuestionTitleDefaultProps, QuestionTitlePropsType } from "./interface";
import { genFontSize } from "../../../../utils/common";
import commonStyles from "../common.module.scss";

const QuestionTitle: React.FC<QuestionTitlePropsType> = (
  props: QuestionTitlePropsType
) => {
  const {
    text,
    level = 1,
    isCenter,
  } = { ...QuestionTitleDefaultProps, ...props };

  return (
    <Typography.Title
      level={level}
      style={{
        marginBottom: "0",
        textAlign: isCenter ? "center" : "start",
        fontSize: genFontSize(level),
      }}
      className={level === 5 ? commonStyles.h5 : ""}
    >
      {text}
    </Typography.Title>
  );
};

export default QuestionTitle;
